package no.hio.wsclient.dao;

import java.util.List;
import java.util.NoSuchElementException;

import no.hio.wsproviderproduct.Product;
import no.hio.wsproviderproduct.ProductService;
import no.hio.wsproviderproduct.ProductServiceImplService;

/**
 * Implementation of ProductDAO
 * @author andreas
 *
 */
public class ProductDAOWebServiceImpl implements ProductDAO {

	ProductService service;
	public ProductDAOWebServiceImpl()
	{
		ProductServiceImplService impl = new ProductServiceImplService();
		service = (ProductService) impl.getProductServicePort();
	}
	
	/* (non-Javadoc)
	 * @see no.hio.wsclient.dao.ProductDAO#findAllProducts()
	 */
	@Override
	public List<Product> findAllProducts() {
		return service.findAllProducts();
	}

	/* (non-Javadoc)
	 * @see no.hio.wsclient.dao.ProductDAO#findByProductID(int)
	 */
	@Override
	public Product findByProductID(int productID) {
		return service.findByProductID(productID);
	}

	/* (non-Javadoc)
	 * @see no.hio.wsclient.dao.ProductDAO#insertProduct(no.hio.wsprovider.Product)
	 */
	@Override
	public int insertProduct(Product product)
			throws UnsupportedOperationException {
		
		return service.insertProduct(product);
	}

	/* (non-Javadoc)
	 * @see no.hio.wsclient.dao.ProductDAO#removeProduct(no.hio.wsprovider.Product)
	 */
	@Override
	public void removeProduct(Product product) throws NoSuchElementException {
		service.removeProduct(product);
		
	}

	/* (non-Javadoc)
	 * @see no.hio.wsclient.dao.ProductDAO#updateProduct(no.hio.wsprovider.Product)
	 */
	@Override
	public void updateProduct(Product product) throws NoSuchElementException {
		service.updateProduct(product);
	}



}
